home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wlpprchg / wallchng.frm < prev    next >
Text File  |  1995-09-06  |  9KB  |  348 lines

  1. VERSION 2.00
  2. Begin Form WallChng 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Wall Change"
  6.    ClientHeight    =   2325
  7.    ClientLeft      =   3120
  8.    ClientTop       =   2655
  9.    ClientWidth     =   2610
  10.    Height          =   2730
  11.    Icon            =   WALLCHNG.FRX:0000
  12.    Left            =   3060
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    Picture         =   WALLCHNG.FRX:0302
  17.    ScaleHeight     =   2325
  18.    ScaleWidth      =   2610
  19.    Top             =   2310
  20.    Width           =   2730
  21.    Begin CommandButton Quit 
  22.       Caption         =   "Quit"
  23.       Height          =   375
  24.       Left            =   1416
  25.       TabIndex        =   6
  26.       Top             =   1068
  27.       Width           =   735
  28.    End
  29.    Begin CommandButton About 
  30.       Caption         =   "About"
  31.       Height          =   375
  32.       Left            =   372
  33.       TabIndex        =   5
  34.       Top             =   1068
  35.       Width           =   735
  36.    End
  37.    Begin ComboBox Combo1 
  38.       BackColor       =   &H000000FF&
  39.       ForeColor       =   &H00FF0000&
  40.       Height          =   300
  41.       Left            =   510
  42.       TabIndex        =   0
  43.       Text            =   "Combo1"
  44.       Top             =   570
  45.       Width           =   1530
  46.    End
  47.    Begin Timer Timer5 
  48.       Interval        =   1315
  49.       Left            =   1440
  50.       Top             =   0
  51.    End
  52.    Begin Timer Timer4 
  53.       Interval        =   1210
  54.       Left            =   1080
  55.       Top             =   15
  56.    End
  57.    Begin Timer Timer3 
  58.       Interval        =   1105
  59.       Left            =   705
  60.       Top             =   0
  61.    End
  62.    Begin Timer Timer2 
  63.       Interval        =   1000
  64.       Left            =   375
  65.       Top             =   0
  66.    End
  67.    Begin Timer Timer1 
  68.       Left            =   0
  69.       Top             =   0
  70.    End
  71.    Begin Label icon4 
  72.       Caption         =   "icon4"
  73.       DragIcon        =   WALLCHNG.FRX:0AB2
  74.       Height          =   192
  75.       Left            =   2004
  76.       TabIndex        =   4
  77.       Top             =   720
  78.       Visible         =   0   'False
  79.       Width           =   576
  80.    End
  81.    Begin Label icon3 
  82.       Caption         =   "icon3"
  83.       DragIcon        =   WALLCHNG.FRX:0DB4
  84.       Height          =   216
  85.       Left            =   1992
  86.       TabIndex        =   3
  87.       Top             =   468
  88.       Visible         =   0   'False
  89.       Width           =   588
  90.    End
  91.    Begin Label icon2 
  92.       Caption         =   "icon2"
  93.       DragIcon        =   WALLCHNG.FRX:10B6
  94.       Height          =   216
  95.       Left            =   1992
  96.       TabIndex        =   2
  97.       Top             =   240
  98.       Visible         =   0   'False
  99.       Width           =   588
  100.    End
  101.    Begin Label icon1 
  102.       Caption         =   "icon1"
  103.       DragIcon        =   WALLCHNG.FRX:13B8
  104.       Height          =   192
  105.       Left            =   2028
  106.       TabIndex        =   1
  107.       Top             =   0
  108.       Visible         =   0   'False
  109.       Width           =   540
  110.    End
  111. End
  112. DefInt A-Z
  113. Declare Sub SystemParametersInfo Lib "User" (ByVal wAction%, ByVal wParam%, lParam As Any, ByVal fWinIni%)
  114. Declare Function GetFreeSpace Lib "Kernel" (ByVal wFlags As Integer) As Long
  115. Declare Function GetModuleHandle Lib "Kernel" (ByVal ModName$)
  116. Declare Function GetHeapSpaces& Lib "Kernel" (ByVal hModule)
  117. Declare Function DiskInfo Lib "DiskInfo.DLL" (ByVal DriveNum%, ByVal DriveInfo%) As Long
  118.  
  119. Dim WallPaperFile As String
  120. Dim Called As String
  121. Dim CapSwitch As String
  122. Dim timeloop As Integer
  123. Dim mem As String
  124. Dim res As String
  125. Dim disk(3 To 5) As String
  126. Dim tim As String
  127. Dim MyTime As String
  128. Dim OldMyTime As String
  129. Dim Hours As Integer
  130. Dim x As Integer
  131.  
  132. Sub About_Click ()
  133.     ret$ = Chr$(13) + Chr$(10)
  134.     title$ = "About"
  135.     msg$ = "   Wallpaper Changer - Version 8/92" + ret$ + ret$
  136.     msg$ = msg$ + "        By Tim Hitchings (73637,66)" + ret$ + ret$
  137.     msg$ = msg$ + "Special Thanks:  " + ret$
  138.     msg$ = msg$ + "╖ The Waite Group's Visual Basic How-To" + ret$
  139.     msg$ = msg$ + "╖ Ian Taylor for the DiskInfo.DLL" + ret$
  140.     msg$ = msg$ + "╖ Nelson Ford for VB-Tips"
  141.     MsgBox msg$, 0, title$
  142. End Sub
  143.  
  144. Sub combo1_click ()
  145.   If combo1.text = "30 Minutes" Then
  146.     timer1.interval = 60000
  147.     timeloop = 30
  148.   ElseIf combo1.text = " 5 Minutes" Then
  149.     timer1.interval = 60000
  150.     timeloop = 5
  151.   ElseIf combo1.text = " 1 Minute" Then
  152.     timer1.interval = 60000
  153.   ElseIf combo1.text = "30 Seconds" Then
  154.     timer1.interval = 30000
  155.   ElseIf combo1.text = "10 Seconds" Then
  156.     timer1.interval = 10000
  157.   ElseIf combo1.text = " 1 Second" Then
  158.     timer1.interval = 1000
  159.   ElseIf combo1.text = "PAUSE" Then
  160.     timer1.interval = 0
  161.   End If
  162.   combo1.Refresh
  163.   windowstate = 1
  164. End Sub
  165.  
  166. Sub DirBMP ()
  167.     Called = "Y"
  168.     Filespec$ = "*.BMP"
  169.     WallPaperFile = Dir$(Filespec$)
  170.     If Len(WallPaperFile) = 0 Then
  171.     title$ = "Fatal Error"
  172.     msg$ = "You must put WALLCHNG.EXE in your WINDOWS DIRECTORY!"
  173.     response% = MsgBox(msg$, 16, title$)
  174.     Unload Wallchng
  175.     End
  176.     End If
  177. End Sub
  178.  
  179. Sub DirBMP2 ()
  180.     Filespec$ = "*.BMP"
  181.     WallPaperFile = Dir$
  182.     If Len(WallPaperFile) = 0 Then
  183.     DirBMP
  184.     End If
  185. End Sub
  186.  
  187. Sub Form_Load ()
  188.   combo1.AddItem "PAUSE"
  189.   combo1.AddItem " 1 Second"
  190.   combo1.AddItem "10 Seconds"
  191.   combo1.AddItem "30 Seconds"
  192.   combo1.AddItem " 1 Minute"
  193.   combo1.AddItem " 5 Minutes"
  194.   combo1.AddItem "30 Minutes"
  195.   combo1.text = "30 Minutes"
  196.   timer1.interval = 60000
  197.   timeloop = 30
  198.   windowstate = 1
  199.   ResMemDisk
  200.   Wallchng.caption = mem
  201.   CapSwitch = "1"
  202. End Sub
  203.  
  204. Function GetFreeResources (ModuleName$)
  205.     rInfo& = GetHeapSpaces&(GetModuleHandle(ModuleName$))
  206.     Totalr& = HiWord&(rInfo&)
  207.     FreeR& = LoWord(rInfo&)
  208.     GetFreeResources = FreeR& * 100 \ Totalr&
  209. End Function
  210.  
  211.  
  212. Function HiWord& (LongInt&)
  213.     Temp& = LongInt& \ &H10000
  214.     If Temp& < 0 Then Temp& = Temp& + &H10000
  215.     HiWord& = Temp&
  216. End Function
  217.  
  218.  
  219. Function LoWord& (LongInt&)
  220.     Temp& = LongInt& Mod &H10000
  221.     If Temp& < 0 Then Temp& = Temp& + &H10000
  222.     LoWord& = Temp&
  223. End Function
  224.  
  225.  
  226. Function Min (P1, P2)
  227.     If P1 < P2 Then Min = P1 Else Min = P2
  228. End Function
  229.  
  230. Sub Quit_Click ()
  231.     Unload Wallchng
  232.     End
  233. End Sub
  234.  
  235. Sub ResMemDisk ()
  236.   Static SpaceFree As Long
  237.   x = 3
  238.   SpaceFree = DiskInfo(x, 1)
  239.   Do While SpaceFree <> -1
  240.     disk(x) = Chr$(x + 64) + ": " + Format$((SpaceFree \ 1024) \ 1000) + "M free"
  241.     x = x + 1
  242.     If x > 5 Then
  243.     x = 5
  244.     End If
  245.     SpaceFree = DiskInfo(x, 1)
  246.   Loop
  247.   x = 3
  248.   Static OldFreeSpace As Long, FreeSpace As Long
  249.   FreeSpace = GetFreeSpace(0)
  250.   If OldFreeSpace <> FreeSpace Then
  251.     OldFreeSpace = FreeSpace
  252.     mem = "Free memory: " + Format$((FreeSpace \ 1024) \ 1000) + "M"
  253.   End If
  254.   
  255.   TFree = Min(GetFreeResources("User"), GetFreeResources("GDI"))
  256.   If TFree <> OldTotal Then
  257.     OldTotal = TFree
  258.     res = "Free resources: " + Format$(TFree, "00") + "%"
  259.   End If
  260.  
  261.   MyTime = Mid$(Time$, 1, 5)
  262.   If MyTime <> OldMyTime Then
  263.     OldMyTime = MyTime
  264.     Hours = Val(MyTime)
  265.     If Hours > 12 Then Mid$(MyTime, 1, 2) = Str$(Hours - 12)
  266.     tim = "Time:  " + MyTime
  267.   End If
  268. End Sub
  269.  
  270. Sub timer1_timer ()
  271.     If combo1.text = " 5 Minutes" Then
  272.     timeloop = timeloop - 1
  273.     End If
  274.     If combo1.text = "30 Minutes" Then
  275.     timeloop = timeloop - 1
  276.     End If
  277.     If combo1.text = "30 Minutes" Then
  278.     If timeloop = 0 Then
  279.         If Called = "Y" Then
  280.         DirBMP2
  281.         Else
  282.         DirBMP
  283.         End If
  284.         WallPaper$ = WallPaperFile
  285.         SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ByVal WallPaper$, SPIF_UPDATEINIFILE
  286.         timeloop = 30
  287.     End If
  288.     ElseIf combo1.text = " 5 Minutes" Then
  289.     If timeloop = 0 Then
  290.         If Called = "Y" Then
  291.         DirBMP2
  292.         Else
  293.         DirBMP
  294.         End If
  295.         WallPaper$ = WallPaperFile
  296.         SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ByVal WallPaper$, SPIF_UPDATEINIFILE
  297.         timeloop = 5
  298.     End If
  299.     Else
  300.     If Called = "Y" Then
  301.         DirBMP2
  302.     Else